package pers.kw.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import pers.kw.file.api.FileApi;
import pers.kw.file.dto.FileDto;
import pers.kw.protocol.R;
import pers.kw.service.FileService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
public class FileController implements FileApi {

    @Resource
    private FileService fileService;

    @Override
    public R<String> uploadFile(MultipartFile file) throws Exception {
        return fileService.uploadFile(file);
    }

    @Override
    public void downloadFile(HttpServletResponse httpServletResponse, String fileName) throws Exception {
        fileService.downloadFile(httpServletResponse, fileName);
    }

    @Override
    public R<String> getFileExpiryAccessUrl(String fileName) throws Exception {
        return fileService.getFileExpiryAccessUrl(fileName);
    }

}
